package com.ccc.test.mqtt.service;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ccc.test.mqtt.pojo.PointData;
import com.ccc.test.mqtt.pojo.SensorData;
import com.ccc.test.mqtt.push.MqttPushClient;
import com.ccc.test.mqtt.util.MsgUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据处理
 *
 * @author superC
 * @version 1.0.0
 * @date 2023/7/7
 */

@Service
public class DataProcessService {
    private static final Logger logger = LoggerFactory.getLogger(DataProcessService.class);

    /**
     * 处理报文数据
     *
     * @date 2023/7/11 10:31
     * @param topic: 主题
     * @param qos: 服务质量
     * @param msg: 报文内容
     * @return {@link SensorData}
     * @author superC
     */
    public void getSensorData(String topic, int qos, String msg) {
        if (msg != null) {
            SensorData sensorData = MsgUtils.msgConvert(msg);
            logger.info("数据转换完毕！");
            logger.info("转换报文主题：{}", topic);
            logger.info("转换报文内容：{}", sensorData.toString());
        }
    }

}
